/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package utn.frsf.cidisi.upcolbpip.interactionprotocols.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import utn.frsf.cidisi.upcolbpip.interactionprotocols.InteractionProtocolElement;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.InteractionprotocolsPackage;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.TimeExpresion;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Interaction Protocol Element</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.interactionprotocols.impl.InteractionProtocolElementImpl#getName <em>Name</em>}</li>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.interactionprotocols.impl.InteractionProtocolElementImpl#getTimeExpression <em>Time Expression</em>}</li>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.interactionprotocols.impl.InteractionProtocolElementImpl#getId <em>Id</em>}</li>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.interactionprotocols.impl.InteractionProtocolElementImpl#getPredecessor <em>Predecessor</em>}</li>
 *   <li>{@link utn.frsf.cidisi.upcolbpip.interactionprotocols.impl.InteractionProtocolElementImpl#getSuccessor <em>Successor</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public abstract class InteractionProtocolElementImpl extends EObjectImpl implements InteractionProtocolElement {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getTimeExpression() <em>Time Expression</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimeExpression()
	 * @generated
	 * @ordered
	 */
	protected TimeExpresion timeExpression;

	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected String id = ID_EDEFAULT;

	/**
	 * The cached value of the '{@link #getPredecessor() <em>Predecessor</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPredecessor()
	 * @generated
	 * @ordered
	 */
	protected InteractionProtocolElement predecessor;

	/**
	 * The cached value of the '{@link #getSuccessor() <em>Successor</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSuccessor()
	 * @generated
	 * @ordered
	 */
	protected InteractionProtocolElement successor;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected InteractionProtocolElementImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return InteractionprotocolsPackage.Literals.INTERACTION_PROTOCOL_ELEMENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TimeExpresion getTimeExpression() {
		return timeExpression;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetTimeExpression(TimeExpresion newTimeExpression, NotificationChain msgs) {
		TimeExpresion oldTimeExpression = timeExpression;
		timeExpression = newTimeExpression;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__TIME_EXPRESSION, oldTimeExpression, newTimeExpression);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTimeExpression(TimeExpresion newTimeExpression) {
		if (newTimeExpression != timeExpression) {
			NotificationChain msgs = null;
			if (timeExpression != null)
				msgs = ((InternalEObject)timeExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__TIME_EXPRESSION, null, msgs);
			if (newTimeExpression != null)
				msgs = ((InternalEObject)newTimeExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__TIME_EXPRESSION, null, msgs);
			msgs = basicSetTimeExpression(newTimeExpression, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__TIME_EXPRESSION, newTimeExpression, newTimeExpression));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(String newId) {
		String oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public InteractionProtocolElement getPredecessor() {
		if (predecessor != null && predecessor.eIsProxy()) {
			InternalEObject oldPredecessor = (InternalEObject)predecessor;
			predecessor = (InteractionProtocolElement)eResolveProxy(oldPredecessor);
			if (predecessor != oldPredecessor) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__PREDECESSOR, oldPredecessor, predecessor));
			}
		}
		return predecessor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public InteractionProtocolElement basicGetPredecessor() {
		return predecessor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPredecessor(InteractionProtocolElement newPredecessor) {
		InteractionProtocolElement oldPredecessor = predecessor;
		predecessor = newPredecessor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__PREDECESSOR, oldPredecessor, predecessor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public InteractionProtocolElement getSuccessor() {
		if (successor != null && successor.eIsProxy()) {
			InternalEObject oldSuccessor = (InternalEObject)successor;
			successor = (InteractionProtocolElement)eResolveProxy(oldSuccessor);
			if (successor != oldSuccessor) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__SUCCESSOR, oldSuccessor, successor));
			}
		}
		return successor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public InteractionProtocolElement basicGetSuccessor() {
		return successor;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSuccessor(InteractionProtocolElement newSuccessor) {
		InteractionProtocolElement oldSuccessor = successor;
		successor = newSuccessor;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__SUCCESSOR, oldSuccessor, successor));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__TIME_EXPRESSION:
				return basicSetTimeExpression(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__NAME:
				return getName();
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__TIME_EXPRESSION:
				return getTimeExpression();
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__ID:
				return getId();
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__PREDECESSOR:
				if (resolve) return getPredecessor();
				return basicGetPredecessor();
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__SUCCESSOR:
				if (resolve) return getSuccessor();
				return basicGetSuccessor();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__NAME:
				setName((String)newValue);
				return;
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__TIME_EXPRESSION:
				setTimeExpression((TimeExpresion)newValue);
				return;
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__ID:
				setId((String)newValue);
				return;
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__PREDECESSOR:
				setPredecessor((InteractionProtocolElement)newValue);
				return;
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__SUCCESSOR:
				setSuccessor((InteractionProtocolElement)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__NAME:
				setName(NAME_EDEFAULT);
				return;
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__TIME_EXPRESSION:
				setTimeExpression((TimeExpresion)null);
				return;
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__ID:
				setId(ID_EDEFAULT);
				return;
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__PREDECESSOR:
				setPredecessor((InteractionProtocolElement)null);
				return;
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__SUCCESSOR:
				setSuccessor((InteractionProtocolElement)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__TIME_EXPRESSION:
				return timeExpression != null;
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__ID:
				return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__PREDECESSOR:
				return predecessor != null;
			case InteractionprotocolsPackage.INTERACTION_PROTOCOL_ELEMENT__SUCCESSOR:
				return successor != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(", id: ");
		result.append(id);
		result.append(')');
		return result.toString();
	}

} //InteractionProtocolElementImpl
